#ifndef WIDGET_H
#define WIDGET_H

#include <QWidget>
#include <QHBoxLayout>
#include <QComboBox>
#include <QLabel>
#include <QPushButton>
#include <QGridLayout>
#include <QScrollArea>
#include <QPixmap>
#include <QColor>
#include <QTextBrowser>
#include <QMessageBox>
#include <QClipboard>
#include <QApplication>
#include "maze.h"

class Widget : public QWidget
{
    Q_OBJECT

public:
    Widget(QWidget *parent = 0);
    ~Widget();
    static const int UP = 1;
    static const int RIGHT = 2;
    static const int DOWN = 4;
    static const int LEFT = 8;

    //一下用于在panitEvent中标志状态
    //状态存储在drawStatus
    static const int MAZE_DRAWN = 1;
    static const int SOLUTION_DRAWN = 2;
    static const int DRAW_MAZE = 4;
    static const int DRAW_SOLUTION = 8;


    void paintEvent();
    void solve();
    void generateMaze();
    void newMaze(int s);
private:
    //迷宫相关参数
    Maze *helloMaze;
    int mazeSize;
    //迷宫每一个block的像素大小
    int blockSize;
    //两个block的像素间隔
    int blockInteval;
    //迷宫的像素宽高
    int mazeWidth;
    int mazeHeight;

    QColor blockColor;
    QColor wallColor;

    bool showSolution;
    bool iWantToPaint;
    bool savePic;
    int drawStatus;
    QHBoxLayout *mainLayout;
    QGridLayout *rightLayout;


    QLabel *picLabel;
    QScrollArea *picArea;
    //迷宫图片和解法
    QImage *mazeImage;
    QImage *solutionImage;

    QComboBox *sizeCombo;
    QPushButton *solveBtn;
    QPushButton *saveBtn;
    QPushButton *updateBtn;
    QPushButton *giteeBtn;
    QTextBrowser *msgBrowser;
    QMessageBox *saveBox;
    QClipboard *clipBoard;
private slots:
    void drawPath();
    void drawMaze();
    void changeMaze(QString s);
    void saveBtnClicked();
    void updateMaze();
    void giteeBtnClicked();

};

#endif // WIDGET_H
